﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

namespace NLE
{
    static class Functions
    {
        public static Point ToScreenCoords(Control pControl, Point pCoords)
        {
            int w = (int)((float)pControl.Width / 2.0f);
            int h = (int)((float)pControl.Height / 2.0f);

            int sX = (int)(Camera.Instance.Position.X * Camera.Instance.Zoom + pCoords.X - w);
            int sY = (int)(-Camera.Instance.Position.Y * Camera.Instance.Zoom + pCoords.Y - h);

            sX = (int)((float)sX);
            sY = -(int)((float)sY);

            return new Point(sX, sY);
        }

        public static Point GetMouseToScreenCoords(Control pControl)
        {
            System.Drawing.Point local = (new System.Drawing.Point((int)Mouse.X, (int)Mouse.Y));

            Point r = ToScreenCoords(pControl, local);

            return new Point((int)((float)r.X / Camera.Instance.Zoom), (int)((float)r.Y / Camera.Instance.Zoom));
        }
        public static bool Embeds(int x1, int y1, int x2, int y2, int w, int h)
        {
            return x1 > x2 &&
            y1 < y2 &&
            x1 < x2 + w &&
            y1 > y2 - h;
        }

        
    }
}
